package com.project.dao.impl;

import com.project.bean.CountyBean;
import com.project.dao.ICountryDao;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

@Repository
public class CountryDaoImpl extends BaseDao implements ICountryDao {
    @Override
    public List<CountyBean> findAll() {
        List<CountyBean> list = new ArrayList<>();
        this.setConnection();
        try {
            ps = con.prepareStatement("select * from t_country");
            rs = ps.executeQuery();
            while(rs.next()){
                CountyBean countyBean = new CountyBean();
                countyBean.setId(rs.getInt("pk_contryId"));
                countyBean.setName(rs.getString("c_name"));
                list.add(countyBean);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally{
            this.closeConnection();
        }

        return list;
    }
}
